const urlMap={
    // "rootUrl":"https://api-hmugo-web.itheima.net/api/public/v1",
    // "rootUrl": "http://rap2api.taobao.org/app/mock/270709",
    // "rootUrl": "http://localhost:8080",
  "rootUrl": "http://192.168.43.159:8080",
    "swiper":"/home/swiperdata",    // 轮播图
    "navMenu":"/home/catitems",     // 导航菜单

    "goodsCategory":"/categories",     // 商品分类
    "goodsSearch":"/goods/search",     // 商品列表搜索
    "goodsInfo":"/goods/detail",     // 商品详情
    "goodsAdd": "/goods/goodsadd",     // 添加商品
    "feedback": "/feedback",     // 反馈页面
    "goodsQsearch":"/goods/qsearch",     // 搜索建议查询    
   "deletegoods": "/goods/deletegoods",     // 删除商品



    //支付的  没有使用token(模拟的)  支付请求没有使用
    "userToken":"/users/wxlogin",     // 获取用户token--暂时没使用到
    "payParams":"/my/orders/req_unifiedorder",     // 获取支付参数



    //订单
    "createOrder":"/my/orders/create",     // 创建订单
    "daifahuo":"/my/orders/awaitorders", //买方查询等待发货的商品
    "daishouhuo": "/my/orders/awairece", //待收货
    "tuikuan": "/my/orders/tuikuan", //退货
    "allorders": "/my/orders/allorders", //全部订单
    "clicktuikuan": "/my/orders/clicktuikuan", //修改为退款状态
    "confirmget": "/my/orders/confirmget", //修改为退款状态
    "applyreturngoods": "/my/orders/applyreturngoods", //申请退货


    "selldaifahuo": "/my/orders/selldaifahuo", //卖方待发货
    "sellyifahuo": "/my/orders/sellyifahuo", //卖方已发货
    "selltuihuo": "/my/orders/selltuihuo", //卖方退货
    "sellallgoods": "/my/orders/sellallgoods", //卖方全部订单 4 0

    "delivergoods": "/my/orders/delivergoods", //卖方已经发货
    "agreereturn": "/my/orders/agreereturn", //卖方同意退货

    "mysell": "/my/mysell", //卖方同意退货
    "mysellcount": "/my/mysellcount" //卖方同意退货
}
// 同时发送异步请求的次数
let ajaxTime=0;
export const request=(parames)=>{
    ++ajaxTime;
    wx.showLoading({title: '加载中',mask:true});
    parames.url=urlMap.rootUrl+urlMap[parames.name];
    return new Promise((resolve, reject) => {
        wx.request({
            ...parames,
            success (res) {
                resolve(res)
            },fail:(err)=>{
                reject(err)
            },complete:()=>{
                --ajaxTime;
                if(ajaxTime ===0){
                    wx.hideLoading();
                }
            }
        })
    })
}